package com.zyg.apart.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zyg.apart.mapper.LogisticsMapper;
import com.zyg.apart.model.Lessee;
import com.zyg.apart.model.Logistics;
import com.zyg.apart.service.LogisticsService;
import com.zyg.apart.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class LogisticsServiceImpl implements LogisticsService {
    @Autowired
    private LogisticsMapper logisticsMapper;

    @Override
    public PageInfo<Map<String, Object>> getAllLog(Integer currentPage) {
        PageHelper.startPage(currentPage, Const.pageSize);
        List<Map<String,Object>> list = logisticsMapper.getAllLog();
        PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Logistics getLogById(Integer id) {
        return logisticsMapper.getLogById(id);
    }

    @Override
    public int editLog(Logistics logistics) {
        return logisticsMapper.editLog(logistics);
    }

    @Override
    public int addLog(Logistics logistics) {
        Date date = new Date();
        logistics.setLo_create_time(date);
        System.out.println(logistics);
        return logisticsMapper.addLog(logistics);
    }

    @Override
    public int delLog(Integer id) {
        return logisticsMapper.delLogById(id);
    }

    @Override
    public List<Logistics> getAllLogName() {
        return logisticsMapper.getAllLogName();
    }
}
